import keyboard
import pyautogui
import random
import threading


pyautogui.FAILSAFE = False
move_type_list = [pyautogui.easeInQuad, pyautogui.easeOutQuad, pyautogui.easeInOutQuad, pyautogui.easeInBounce, pyautogui.easeInElastic]


def get_exit():
	while True:
		if keyboard.is_pressed('shift+esc'):
			break


def trick():
	screenX, screenY = pyautogui.size()
	duration = random.randint(1, 5)
	while True:
		x = random.randrange(0, screenX)
		y = random.randrange(0, screenY)
		move_type = random.choice(move_type_list)
		pyautogui.moveTo(x, y, duration=duration, tween=move_type)


if __name__ == '__main__':
	thread1 = threading.Thread(target=trick)
	thread2 = threading.Thread(target=get_exit)
	# 修改守护线程，主线程执行完，thread1和主线程一起退出
	thread1.daemon = True
	thread1.start()
	thread2.start()